﻿Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports pizzaLibrary
Imports utilitiesLibrary

<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class pizzaService
    Inherits System.Web.Services.WebService

    Dim objDB As New DBConnect

    <WebMethod()> _
    Public Function GetPizzaInfo(ByRef objInOut As orderLine)
        Dim objPF As New pizzaFunctions(objDB)

        objInOut.piePrice = objPF.pizzaPrice(objInOut.pieSize, objInOut.pizzaType)
        objInOut.isCoupon = objPF.coupon(objInOut.pizzaType)
        objInOut.total = CType(objInOut.quantity, Decimal) * CType(objInOut.piePrice, Decimal)
        objPF.addPieToSales(objInOut.pizzaType, objInOut.total)
        'MsgBox(objInOut.pizzaType.ToString & " " & objInOut.pieSize.ToString & " " & objInOut.quantity.ToString & " " & objInOut.isCoupon.ToString & " " & objInOut.piePrice.ToString)

    End Function

    <WebMethod()> _
    Public Function GetPizzaTable() As DataSet
        'Produce a dataset containing all columns for all pizza records
        Dim ds As New DataSet
        Dim sql As String
        sql = "SELECT * FROM PIZZA"
        ds = objDB.getDataSet(sql)
        Return ds

    End Function

End Class